import Vue from 'vue'
import VueRouter from 'vue-router'
//非懒加载路由
import Home from '@/components/Home.vue'
//路由懒加载
const About = () => import('@/components/About.vue')
const User = () => import('@/components/User.vue')
const Pass = () => import('@/components/Pass.vue')
const Login = () => import('@/components/Login.vue')
const Order = () => import('@/components/Order.vue')
const News = () => import('@/components/News.vue')
const NewsDetail = () => import('@/components/NewsDetail.vue')
Vue.use(VueRouter)

const routes = [
  { path: '/', redirect: '/home' },
  { path: '/home', component: Home },
  { path: '/news', component: News },
  { path: '/news/:id', component: NewsDetail },
  { path: '/about', component: About },
  {
    path: '/user',
    component: User,
    children: [
      { path: 'pass', component: Pass },
      { path: 'order', component: Order }
    ]
  },
  { path: '/login', component: Login }
]

const router = new VueRouter({ routes })

export default router
